
import { LanguageManager } from "../language/LanguageManager";
import { PayType } from "../sdk/PlayableSDK";

const {ccclass, property} = cc._decorator;

@ccclass
export class PayName extends cc.Component {

    @property({ type: cc.Boolean })
    public isFollowLanage: boolean = true;

    @property({
        type: cc.Enum(PayType),
        visible: function () {
            return !this.isFollowLanage;
        } 
    })
    public payType: PayType = PayType.One;

    private payName: cc.Label = null;

    onLoad() {
        this.payName = this.node.getComponent(cc.Label);
    }

    start() {
        this.initName();
    }

    private initName(): void {
        if (this.payName == null)
            return;
    
        let cfg = this.isFollowLanage ? LanguageManager.instance.payAppInfo : LanguageManager.instance.getPayAppInfo(this.payType);
        this.payName.string = cfg.name;
    }
}
